/* eslint-disable eqeqeq */
import React, { Component } from 'react'
import Utils  from '../../utils/utils';
import {Input,Select,Button,Form, DatePicker} from 'antd'
export default class BaseForm extends Component {
    initFormList = ()=>{
        const formList = this.props.formList;
        const formItemList = [];
        if (formList && formList.length>0){
            formList.forEach((item)=>{
                let label = item.label;
                let field = item.field;
                // let initialValue = item.initialValue || '';
                let placeholder = item.placeholder;
                let width = item.width;
                if (item.type == 'SELECT') {
                    const SELECT = <Form.Item label={label} key={field}>
                        <Select
                            style={{width:width}}
                            placeholder={placeholder}
                        >
                            {Utils.getOptionList(item.list)}
                        </Select>
                    </Form.Item>;
                    formItemList.push(SELECT);
                }else if(item.type == 'INPUT'){
                    const INPUT = <Form.Item label={label} key={field}>
                        <Input type="text" placeholder={placeholder}/>
                    </Form.Item>;
                    formItemList.push(INPUT);
                }else if(item.type == '时间查询'){
                    const begin_time = <Form.Item label="订单时间" key="1">
                        <DatePicker showTime format="YYYY-MM-DD HH:mm:ss" name="begin_time"/>
                    </Form.Item>;
                    formItemList.push(begin_time);

                    const end_time = <Form.Item label={label} key="2">
                        <DatePicker showTime format="YYYY-MM-DD HH:mm:ss" name="end_time"/>
                    </Form.Item>;
                    formItemList.push(end_time);
                }
                // else if(item.type == 'CHECKBOX'){
                //     const CHECKBOX = <Form.Item label={label} key={field}>
                //         <Checkbox>
                //             {label}
                //         </Checkbox>
                //     </Form.Item>;
                //     formItemList.push(CHECKBOX);                 
                // }
            })
        }
        return formItemList;
    }

    handleFilterSubmit = () =>{
        // let fieldValue = this.props.getFieldValue();
        // this.props.filterSubmit(fieldValue);
    }

    reset = () =>{
        // console.log(this.props);
    }
    render() {
        return (
            <Form layout="inline">
                { this.initFormList() }
                <Form.Item>
                    <Button type="primary" style={{ margin: '0 20px' }} onClick={this.handleFilterSubmit}>查询</Button>
                    <Button onClick={this.reset}>重置</Button>
                </Form.Item>
            </Form>
        )
    }
}
